package kr.hkit.androidcomplete03.DomParser.common;

import java.util.ArrayList;

import kr.hkit.androidcomplete03.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MyWeatherAdapter extends BaseAdapter {
	private ArrayList<DaeGuWeatherItem> itemList;
	private LayoutInflater inflater;
	private Integer[] weatherImage = { R.drawable.icon01, R.drawable.icon02, R.drawable.icon03, R.drawable.icon04, R.drawable.icon08 };
	
	public MyWeatherAdapter(Context context, ArrayList<DaeGuWeatherItem> arList) {
		this.itemList = arList;
		this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return itemList.size();
	}

	@Override
	public Object getItem(int position) {
		return itemList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.weatherdatarow, parent, false);
						
		}
		
		ImageView weatherIcon = (ImageView) convertView.findViewById(R.id.weatherIcon);
		TextView itemName = (TextView) convertView.findViewById(R.id.itemName);
		//TextView iconData = (TextView) convertView.findViewById(R.id.iconData);
		TextView tempDate = (TextView) convertView.findViewById(R.id.tempDate);
		TextView descData = (TextView) convertView.findViewById(R.id.descData);

		
		itemName.setText(itemList.get(position).getItemName());
		//iconData.setText(itemList.get(position).getIcon());
		tempDate.setText(itemList.get(position).getTemp());
		descData.setText(itemList.get(position).getDesc());

		/*if((itemList.get(position).getIcon()).equals(01)){
			weatherIcon.setBackgroundColor(R.drawable.coin50);
		}*/
		
		convertView.setTag(getItem(position));
		
		return convertView;
	}

}
